package com.wk.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wk.dao.CmfzRoleDao;
import com.wk.entity.CmfzRole;
import com.wk.entity.Result;
import com.wk.service.CmfzRoleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class CmfzRoleServiceImpl implements CmfzRoleService {

    @Autowired
    private CmfzRoleDao cmfzRoleDao;


    @Override
    public Result findByPage(Integer page, Integer limit) {

        Page<CmfzRole> page1 = new Page<CmfzRole>(page,limit);

        Page<CmfzRole> cmfzRolePage = cmfzRoleDao.selectPage(page1, null);

        List<CmfzRole> records = cmfzRolePage.getRecords();
        log.info("查询到的角色数据"+records);

        long total = cmfzRolePage.getTotal();

        return new Result().setData(records).setCount((int) total).setCode(0).setMsg("");
    }

    @Override
    public List findAll() {
        return cmfzRoleDao.selectList(null);
    }
}
